#!/usr/bin/perl

sub trim($);
sub ltrim($);
sub rtrim($);

sub trim($)
{
	my $trim_string = shift;
	$trim_string =~ s/^\s+//;
	$trim_string =~ s/\s+$//;
	return $trim_string;
}

sub ltrim($)
{
	my $trim_string = shift;
	$trim_string =~ s/^\s+//;
	return $trim_string;
}

sub rtrim($)
{
	my $trim_string = shift;
	$trim_string =~ s/\s+$//;
	return $trim_string;
}

use strict;
use warnings;

open FILE1, "<", "../../MISC/ListOfStocks" or die $!;
open FILE2, ">", "../../MISC/CleanListOfStocks";

while(<FILE1>){
	my $line=trim($_);
	if (substr($line, 0, 1) ne "#") {
		($line)= split /\s/, $line, 2; #cut after first occurence of whitespace
	}
	print $line."\n";
	print FILE2 $line."\n";
}

close(FILE1);
close(FILE2);
